package com.hpq.chat.domain.model;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.hpq.chat.domain.enums.HotFlagEnum;
import com.hpq.chat.domain.enums.RoomTypeEnum;
import lombok.*;

import java.io.Serializable;
import java.util.Date;

@Data
@EqualsAndHashCode(callSuper = false)
@TableName("room")
public class Room implements Serializable {
    private static final long serialVersionUID = 1L;
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;
    /**
     * 房间类型(1:群聊;2:私聊)
     */
    private Integer type;
    /**
     *是否全员展示(0:否;1:是)
     */
    private Integer hotFlag;
    /**
     *群最后消息的更新时间
     */
    private Date activeTime;
    /**
     * 最后一条消息id
     */
    private Long lastMsgId;
    /**
     *额外信息(根据不同房间有不同存储的东西）
     */
    private String extJson;
    /**
     *创建时间
     */
    private Date createTime;
    /**
     * 修改时间
     */
    private Date updateTime;
    @JsonIgnore
    public boolean isHotRoom() {
        return HotFlagEnum.of(this.hotFlag) == HotFlagEnum.YES;
    }

    /**
     *  是否是好友房间
     * @return
     */
    @JsonIgnore
    public boolean isRoomFriend() {
        return RoomTypeEnum.of(this.type) == RoomTypeEnum.FRIEND;
    }

    /**
     *  是否是群聊房间
     * @return
     */
    @JsonIgnore
    public boolean isRoomGroup() {
        return RoomTypeEnum.of(this.type) == RoomTypeEnum.GROUP;
    }


}
